package com.gitee.wsl.mathematics.matrix.ext

import com.gitee.wsl.mathematics.base.NumberMapping16
import com.gitee.wsl.mathematics.base.NumberMapping4
import com.gitee.wsl.mathematics.base.NumberMapping9
import com.gitee.wsl.mathematics.matrix.mat2.Matrix2
import com.gitee.wsl.mathematics.matrix.mat3.Matrix3
import com.gitee.wsl.mathematics.matrix.mat4.Matrix4


/** Call [f] on all [this] matrix components given row by row and return it's result. */
internal inline fun <T:Number,R> Matrix2<T,*,*>.reduce(f: NumberMapping4<T,R>): R = f(
    m00, m01,
    m10, m11
)

/** Call [f] on all [this] matrix components given row by row and return it's result. */
internal inline fun <T:Number,R> Matrix3<T,*,*>.reduce(f: NumberMapping9<T,R>): R = f(
    m00, m01, m02,
    m10, m11, m12,
    m20, m21, m22
)

/** Call [f] on all [this] matrix components given row by row and return it's result. */
internal inline fun <T:Number,R> Matrix4<T,*,*>.reduce(f: NumberMapping16<T,R>): R = f(
    m00, m01, m02, m03,
    m10, m11, m12, m13,
    m20, m21, m22, m23,
    m30, m31, m32, m33
)